package com.meetingshow.commu.service.util;

import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.meetingshow.common.base.dao.model.QueryStruct;
import com.meetingshow.common.base.service.BaseQueryParasBuilder;
import com.meetingshow.commu.service.model.AnswerQueryParas;

public class AnswerQueryParasBuilder extends BaseQueryParasBuilder {
    public static QueryStruct answerQueryBuilder(
            QueryStruct queryStruct, AnswerQueryParas answerQueryParas)
            throws Exception {
        
        builderInit(answerQueryParas, queryStruct);

        Map<String, Object> exactMap = queryStruct.getExactMap();
        
        if (StringUtils.isNotBlank(answerQueryParas.getAnswerId_e())) {
            exactMap.put(AnswerServiceParas.ANSWER_PO_ID, Integer.valueOf(answerQueryParas.getAnswerId_e()));
        }
        
        if (StringUtils.isNotBlank(answerQueryParas.getQuestionId_e())) {
            exactMap.put(AnswerServiceParas.ANSWER_PO_QUESTION_ID, Integer.valueOf(answerQueryParas.getQuestionId_e()));
        }
        
        if (StringUtils.isNotBlank(answerQueryParas.getFromUserId_e())) {
            exactMap.put(AnswerServiceParas.ANSWER_PO_FROM_USER_ID, Integer.valueOf(answerQueryParas.getFromUserId_e()));
        }
        
        if (StringUtils.isNotBlank(answerQueryParas.getToUserId_e())) {
            exactMap.put(AnswerServiceParas.ANSWER_PO_TO_USER_ID, Integer.valueOf(answerQueryParas.getToUserId_e()));
        }
        
        if (StringUtils.isNotBlank(answerQueryParas.getTopicId_e())) {
            exactMap.put(AnswerServiceParas.ANSWER_PO_TOPIC_ID, Integer.valueOf(answerQueryParas.getTopicId_e()));
        }
        
        pageBuilder(queryStruct, answerQueryParas);
        
        return queryStruct;
    }
}
